package com.github.dice.constant;

public enum ErrorEnums {
    E_0000("E_0000", "成功"),
    E_0001("E_0001", "非法入参"),

    E_4001("E_4001", "房间密码错误"),
    E_4002("E_4002", "房间人数超限"),

    E_5001("E_5001", "玩家登录失败"),
    E_5002("E_5002", "玩家未登录"),
    E_5003("E_5003", "玩家创建失败"),

    E_6001("E_6001", "不存在该房主的信息"),
    E_6002("E_6002", "非当前房主，无法显示结果"),
    E_6003("E_6003", "房主创建失败"),
    E_6004("E_6004", "房主登录失败"),
    E_6005("E_6005", "房主未登录"),
    E_6006("E_6006", "非法登录"),
    E_6007("E_6007", "该房间已在使用，创建失败"),

    E_7001("E_7001", "已经投过骰子"),
    E_7002("E_7002", "还有其他玩家未投骰子"),

    E_9999("E_9999", "未知错误");

    private String code;

    private String msg;

    ErrorEnums(String code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    public String getCode() {
        return code;
    }

    public String getMsg() {
        return msg;
    }

    public ErrorEnums getValueOfCode(String code) {
        for (ErrorEnums item : ErrorEnums.values()) {
            if (item.getCode().equals(code)) {
                return item;
            }
        }
        return null;
    }


}
